<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%--
  Created by IntelliJ IDEA.
  User: 张俊杰
  Date: 2017/12/1
  Time: 14:42
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <base href="${pageContext.request.contextPath}/">
    <title>销售机会管理</title>
    <link href="css/style.css" rel="stylesheet" type="text/css">
    <script src="js/jquery-1.9.0.js"></script>
    <script src="script/common.js"></script>
    <script>
        $(function () {
            $(".op_button_del").on("click",function () {
                var chcId = $(this);
                if (window.confirm("确认删除？")){
                    $.ajax({
                        url:"salc/del",
                        data:"chcId="+chcId.attr("value"),
                        success:function () {
                            alert("删除成功");
                           $(chcId).parent().parent().remove();
                        },
                        error:function () {
                            alert("删除失败");
                        }
                    });
                }
            })
        })
    </script>
</head>
<body>
    <div class="page_title">销售机会管理</div>
        <div class="button_bar">
            <button class="common_button" onclick="help('');">帮助</button>
            <button class="common_button" onclick="to('Views/~sale/addZjj.jsp');">新建</button>
            <button class="common_button" onclick="reload();">查询</button>
        </div>
    <table class="query_form_table">
        <tr>
            <th>客户名称</th>
            <td><input id="chcCustName"/></td>
            <th>概要</th>
            <td><input id="chcTitle"/></td>
            <th>联系人</th>
            <td>
                <input name="T1" size="20" id="chcLinkman"/>
            </td>
        </tr>
    </table>
    <br/>
    <table class="data_list_table">
        <tr>
            <th>编号</th>
            <th>客户名称</th>
            <th>概要</th>
            <th>联系人</th>
            <th>联系人电话</th>
            <th>创建时间</th>
            <th>操作</th>
        </tr>
        <c:forEach items="${salChances}" var="salChance" varStatus="num">
            <tr>
                <td class="list_data_number">${num.count}</td>
                <td class="list_data_text">${salChance.chcCustName}</td>
                <td class="list_data_ltext">${salChance.chcTitle}</td>
                <td class="list_data_text">${salChance.chcLinkman}</td>
                <td class="list_data_text">${salChance.chcTel}</td>
                <td class="list_data_text" time>

                    ${salChance.chcCreateDate}
                    
                </td>
                <td class="list_data_op">
                    <img onclick="to('salc/dispatch?chcId=${salChance.chcId}');" title="指派" src="images/bt_linkman.gif" class="op_button"/>
                    <img onclick="to('salc/edit?chcId=${salChance.chcId}');" title="编辑" src="images/bt_edit.gif" class="op_button"/>
                    <img title="删除" src="images/bt_del.gif" class="op_button op_button_del" value=" ${salChance.chcId}"/>

                </td>
            </tr>

        </c:forEach>
        <tr>
            <th colspan="7" class="pager">
                <div class="pager">
                    共${salChancePage.totalRow}条记录 每页<input value="${salChancePage.pageSize}" size="2"/>条
                    第<input value="${salChancePage.pageNo}" size="2"/>页/共${salChancePage.totalPage}页
                    <c:if test="${not (salChancePage.pageNo eq 1)}">
                        <a href="salc/scPage?pageNo=1">第一页</a>
                        <a href="salc/scPage?pageNo=${salChancePage.pageNo-1}">上一页</a>
                    </c:if>
                    <c:if test="${not (salChancePage.pageNo eq salChancePage.totalPage)}">
                        <a href="salc/scPage?pageNo=${salChancePage.pageNo+1}">下一页</a>
                        <a href="salc/scPage?pageNo=${salChancePage.totalPage}">最后一页</a>
                    </c:if>
                    转到<input value="1" size="2" id="pageNo"/>页
                    <button width="20" onclick="reloadGo();">GO</button>
                </div>
            </th>
        </tr>
    </table>
</body>
<script>
    $(function(){
       var time=$("*[time]");
      var newDate = new Date();
        var val=$.trim($(time[0]).text());

       for (var i=0;i<time.length;i++){
           var val=$.trim($(time[i]).text());
             if(val == '0'){
                 $(time[i]).html("");
             }else {
                 newDate.setTime(val);
                 $(time[i]).html(newDate.toLocaleDateString());
             }
       }
    })
</script>
</html>
